{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "458141c5",
   "metadata": {},
   "source": [
    "## 引入库"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a2cf3f80",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas\n",
    "import datetime"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ca2cf30a",
   "metadata": {},
   "source": [
    "## 打开文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "21b3b141",
   "metadata": {},
   "outputs": [],
   "source": [
    "def openfile():\n",
    "    df = pandas.read_csv('gaze.csv')\n",
    "    return df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ad691f7b",
   "metadata": {},
   "source": [
    "## 第一题，保留0.9以上confidence数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "e092854e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "        gaze_timestamp  world_index  confidence  norm_pos_x  norm_pos_y  \\\n",
      "21        88150.825638            2    0.915197    0.493612    0.398950   \n",
      "22        88150.827729            2    0.915197    0.493561    0.399305   \n",
      "23        88150.829663            2    0.915197    0.493570    0.399542   \n",
      "39        88150.866015            3    0.922197    0.492592    0.398705   \n",
      "40        88150.869620            3    0.922197    0.492635    0.398814   \n",
      "...                ...          ...         ...         ...         ...   \n",
      "125259    88443.695600         8788    0.995336    0.407831    0.413470   \n",
      "125260    88443.697570         8788    0.948733    0.407552    0.414731   \n",
      "125261    88443.701580         8788    0.945284    0.407467    0.414705   \n",
      "125262    88443.703608         8788    0.945284    0.407160    0.415340   \n",
      "125263    88443.705574         8788    0.945284    0.407637    0.413674   \n",
      "\n",
      "                                 base_data  gaze_point_3d_x  gaze_point_3d_y  \\\n",
      "21           88150.827729-0 88150.823548-1         2.412810       -21.468145   \n",
      "22           88150.827729-0 88150.827729-1         2.429837       -21.374413   \n",
      "23      88150.827729-0 88150.83159799999-1         2.427118       -21.328193   \n",
      "39      88150.867514-0 88150.86451599999-1         2.827911       -21.750938   \n",
      "40           88150.867514-0 88150.871726-1         2.813774       -21.744854   \n",
      "...                                    ...              ...              ...   \n",
      "125259        88443.69561-0 88443.695591-1       327.648915      -173.027524   \n",
      "125260   88443.69561-0 88443.69953099999-1       311.054477      -161.381388   \n",
      "125261  88443.703629-0 88443.69953099999-1       313.566509      -162.585330   \n",
      "125262       88443.703629-0 88443.703587-1       297.019831      -152.352987   \n",
      "125263  88443.703629-0 88443.70751899999-1       323.629974      -170.142461   \n",
      "\n",
      "        gaze_point_3d_z  eye_center0_3d_x  ...  eye_center0_3d_z  \\\n",
      "21          -295.071057         20.000000  ...        -20.000000   \n",
      "22          -294.819200         20.000000  ...        -20.000000   \n",
      "23          -294.874516         20.000000  ...        -20.000000   \n",
      "39          -298.233245         20.000000  ...        -20.000000   \n",
      "40          -298.471253         20.000000  ...        -20.000000   \n",
      "...                 ...               ...  ...               ...   \n",
      "125259     -2777.243340         19.888755  ...        -20.707271   \n",
      "125260     -2628.637408         19.888755  ...        -20.707271   \n",
      "125261     -2647.420719         19.888755  ...        -20.707271   \n",
      "125262     -2499.428189         19.888755  ...        -20.707271   \n",
      "125263     -2737.404466         19.888755  ...        -20.707271   \n",
      "\n",
      "        gaze_normal0_x  gaze_normal0_y  gaze_normal0_z  eye_center1_3d_x  \\\n",
      "21            0.062883        0.025100        0.997705        -39.934928   \n",
      "22            0.062883        0.025100        0.997705        -39.934928   \n",
      "23            0.062883        0.025100        0.997705        -39.934928   \n",
      "39            0.060717        0.025220        0.997836        -39.934928   \n",
      "40            0.060717        0.025220        0.997836        -39.934928   \n",
      "...                ...             ...             ...               ...   \n",
      "125259       -0.110854        0.041843        0.992955        -37.372594   \n",
      "125260       -0.110854        0.041843        0.992955        -37.372594   \n",
      "125261       -0.111009        0.041794        0.992940        -37.372594   \n",
      "125262       -0.111009        0.041794        0.992940        -37.372594   \n",
      "125263       -0.111009        0.041794        0.992940        -37.372594   \n",
      "\n",
      "        eye_center1_3d_y  eye_center1_3d_z  gaze_normal1_x  gaze_normal1_y  \\\n",
      "21             14.997919        -20.075283       -0.150041        0.234536   \n",
      "22             14.997919        -20.075283       -0.150243        0.234115   \n",
      "23             14.997919        -20.075283       -0.150210        0.233747   \n",
      "39             14.997919        -20.075283       -0.149814        0.233510   \n",
      "40             14.997919        -20.075283       -0.149645        0.233258   \n",
      "...                  ...               ...             ...             ...   \n",
      "125259         14.763454        -23.294339       -0.130868        0.093021   \n",
      "125260         14.763454        -23.294339       -0.132037        0.091860   \n",
      "125261         14.763454        -23.294339       -0.132037        0.091860   \n",
      "125262         14.763454        -23.294339       -0.133311        0.091656   \n",
      "125263         14.763454        -23.294339       -0.131320        0.092941   \n",
      "\n",
      "        gaze_normal1_z  \n",
      "21            0.960458  \n",
      "22            0.960530  \n",
      "23            0.960624  \n",
      "39            0.960744  \n",
      "40            0.960831  \n",
      "...                ...  \n",
      "125259        0.987026  \n",
      "125260        0.986979  \n",
      "125261        0.986979  \n",
      "125262        0.986827  \n",
      "125263        0.986974  \n",
      "\n",
      "[87442 rows x 21 columns]\n"
     ]
    }
   ],
   "source": [
    "def ExcludingLowCredibilty():\n",
    "    df = openfile()\n",
    "    newdf = df[df['confidence'] >= 0.9]\n",
    "    return newdf\n",
    "print(ExcludingLowCredibilty())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f2071ebd",
   "metadata": {},
   "source": [
    "## 第二题，3sigma原则"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "7a9355fb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.4102730721935667 0.43831972720237095 0.2095237213205806 0.21608852429527314\n",
      "        gaze_timestamp  world_index  confidence  norm_pos_x  norm_pos_y  \\\n",
      "0         88150.776780            0    0.828006    0.531433    0.397509   \n",
      "1         88150.776787            0    0.459705    0.337051    0.186147   \n",
      "2         88150.779709            0    0.888789    0.543140    0.410668   \n",
      "3         88150.779759            0    0.550258    0.337923    0.173301   \n",
      "4         88150.787485            1    0.502595    0.340109    0.142989   \n",
      "...                ...          ...         ...         ...         ...   \n",
      "125259    88443.695600         8788    0.995336    0.407831    0.413470   \n",
      "125260    88443.697570         8788    0.948733    0.407552    0.414731   \n",
      "125261    88443.701580         8788    0.945284    0.407467    0.414705   \n",
      "125262    88443.703608         8788    0.945284    0.407160    0.415340   \n",
      "125263    88443.705574         8788    0.945284    0.407637    0.413674   \n",
      "\n",
      "                                 base_data  gaze_point_3d_x  gaze_point_3d_y  \\\n",
      "0                            88150.77678-0        28.369753        52.033135   \n",
      "1                           88150.776787-1      -142.869866       154.788121   \n",
      "2                           88150.779709-0        38.942051        45.359863   \n",
      "3                           88150.779759-1      -141.879169       160.867779   \n",
      "4                           88150.787485-1      -139.404860       175.088321   \n",
      "...                                    ...              ...              ...   \n",
      "125259        88443.69561-0 88443.695591-1       327.648915      -173.027524   \n",
      "125260   88443.69561-0 88443.69953099999-1       311.054477      -161.381388   \n",
      "125261  88443.703629-0 88443.69953099999-1       313.566509      -162.585330   \n",
      "125262       88443.703629-0 88443.703587-1       297.019831      -152.352987   \n",
      "125263  88443.703629-0 88443.70751899999-1       323.629974      -170.142461   \n",
      "\n",
      "        gaze_point_3d_z  eye_center0_3d_x  ...  eye_center0_3d_z  \\\n",
      "0            705.121116         20.000000  ...        -20.000000   \n",
      "1            684.981621        -39.934928  ...        -20.075283   \n",
      "2            705.232112         20.000000  ...        -20.000000   \n",
      "3            683.893108        -39.934928  ...        -20.075283   \n",
      "4            681.151453        -39.934928  ...        -20.075283   \n",
      "...                 ...               ...  ...               ...   \n",
      "125259     -2777.243340         19.888755  ...        -20.707271   \n",
      "125260     -2628.637408         19.888755  ...        -20.707271   \n",
      "125261     -2647.420719         19.888755  ...        -20.707271   \n",
      "125262     -2499.428189         19.888755  ...        -20.707271   \n",
      "125263     -2737.404466         19.888755  ...        -20.707271   \n",
      "\n",
      "        gaze_normal0_x  gaze_normal0_y  gaze_normal0_z  eye_center1_3d_x  \\\n",
      "0             0.011527        0.051002        0.998632               NaN   \n",
      "1            -0.141761        0.192518        0.971000               NaN   \n",
      "2             0.026087        0.041811        0.998785               NaN   \n",
      "3            -0.140397        0.200891        0.969501               NaN   \n",
      "4            -0.136989        0.220475        0.965725               NaN   \n",
      "...                ...             ...             ...               ...   \n",
      "125259       -0.110854        0.041843        0.992955        -37.372594   \n",
      "125260       -0.110854        0.041843        0.992955        -37.372594   \n",
      "125261       -0.111009        0.041794        0.992940        -37.372594   \n",
      "125262       -0.111009        0.041794        0.992940        -37.372594   \n",
      "125263       -0.111009        0.041794        0.992940        -37.372594   \n",
      "\n",
      "        eye_center1_3d_y  eye_center1_3d_z  gaze_normal1_x  gaze_normal1_y  \\\n",
      "0                    NaN               NaN             NaN             NaN   \n",
      "1                    NaN               NaN             NaN             NaN   \n",
      "2                    NaN               NaN             NaN             NaN   \n",
      "3                    NaN               NaN             NaN             NaN   \n",
      "4                    NaN               NaN             NaN             NaN   \n",
      "...                  ...               ...             ...             ...   \n",
      "125259         14.763454        -23.294339       -0.130868        0.093021   \n",
      "125260         14.763454        -23.294339       -0.132037        0.091860   \n",
      "125261         14.763454        -23.294339       -0.132037        0.091860   \n",
      "125262         14.763454        -23.294339       -0.133311        0.091656   \n",
      "125263         14.763454        -23.294339       -0.131320        0.092941   \n",
      "\n",
      "        gaze_normal1_z  \n",
      "0                  NaN  \n",
      "1                  NaN  \n",
      "2                  NaN  \n",
      "3                  NaN  \n",
      "4                  NaN  \n",
      "...                ...  \n",
      "125259        0.987026  \n",
      "125260        0.986979  \n",
      "125261        0.986979  \n",
      "125262        0.986827  \n",
      "125263        0.986974  \n",
      "\n",
      "[120036 rows x 21 columns]\n"
     ]
    }
   ],
   "source": [
    "def RuleOfThumb():\n",
    "    df = openfile()\n",
    "    ux = df['norm_pos_x'].mean()\n",
    "    uy = df['norm_pos_y'].mean()\n",
    "    stdx = df['norm_pos_x'].std()\n",
    "    stdy = df['norm_pos_y'].std()\n",
    "    print(ux, uy, stdx, stdy)\n",
    "    newdf = df[(df['norm_pos_x'] > (ux - 3 * stdx))  & (df['norm_pos_x'] < (ux + 3 * stdx)) &\n",
    "               (df['norm_pos_y'] > (uy - 3 * stdy))  & (df['norm_pos_y'] < (uy + 3 * stdy))]\n",
    "    return newdf\n",
    "print(RuleOfThumb())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f3283a35",
   "metadata": {},
   "source": [
    "## 第三题，改变时间戳形式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "3bea5106",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                            gaze_timestamp  world_index  confidence  \\\n",
      "0      1970-01-01 00:00:00.000088150+00:00            0    0.828006   \n",
      "1      1970-01-01 00:00:00.000088150+00:00            0    0.459705   \n",
      "2      1970-01-01 00:00:00.000088150+00:00            0    0.888789   \n",
      "3      1970-01-01 00:00:00.000088150+00:00            0    0.550258   \n",
      "4      1970-01-01 00:00:00.000088150+00:00            1    0.502595   \n",
      "...                                    ...          ...         ...   \n",
      "125259 1970-01-01 00:00:00.000088443+00:00         8788    0.995336   \n",
      "125260 1970-01-01 00:00:00.000088443+00:00         8788    0.948733   \n",
      "125261 1970-01-01 00:00:00.000088443+00:00         8788    0.945284   \n",
      "125262 1970-01-01 00:00:00.000088443+00:00         8788    0.945284   \n",
      "125263 1970-01-01 00:00:00.000088443+00:00         8788    0.945284   \n",
      "\n",
      "        norm_pos_x  norm_pos_y                           base_data  \\\n",
      "0         0.531433    0.397509                       88150.77678-0   \n",
      "1         0.337051    0.186147                      88150.776787-1   \n",
      "2         0.543140    0.410668                      88150.779709-0   \n",
      "3         0.337923    0.173301                      88150.779759-1   \n",
      "4         0.340109    0.142989                      88150.787485-1   \n",
      "...            ...         ...                                 ...   \n",
      "125259    0.407831    0.413470        88443.69561-0 88443.695591-1   \n",
      "125260    0.407552    0.414731   88443.69561-0 88443.69953099999-1   \n",
      "125261    0.407467    0.414705  88443.703629-0 88443.69953099999-1   \n",
      "125262    0.407160    0.415340       88443.703629-0 88443.703587-1   \n",
      "125263    0.407637    0.413674  88443.703629-0 88443.70751899999-1   \n",
      "\n",
      "        gaze_point_3d_x  gaze_point_3d_y  gaze_point_3d_z  eye_center0_3d_x  \\\n",
      "0             28.369753        52.033135       705.121116         20.000000   \n",
      "1           -142.869866       154.788121       684.981621        -39.934928   \n",
      "2             38.942051        45.359863       705.232112         20.000000   \n",
      "3           -141.879169       160.867779       683.893108        -39.934928   \n",
      "4           -139.404860       175.088321       681.151453        -39.934928   \n",
      "...                 ...              ...              ...               ...   \n",
      "125259       327.648915      -173.027524     -2777.243340         19.888755   \n",
      "125260       311.054477      -161.381388     -2628.637408         19.888755   \n",
      "125261       313.566509      -162.585330     -2647.420719         19.888755   \n",
      "125262       297.019831      -152.352987     -2499.428189         19.888755   \n",
      "125263       323.629974      -170.142461     -2737.404466         19.888755   \n",
      "\n",
      "        ...  eye_center0_3d_z  gaze_normal0_x  gaze_normal0_y  gaze_normal0_z  \\\n",
      "0       ...        -20.000000        0.011527        0.051002        0.998632   \n",
      "1       ...        -20.075283       -0.141761        0.192518        0.971000   \n",
      "2       ...        -20.000000        0.026087        0.041811        0.998785   \n",
      "3       ...        -20.075283       -0.140397        0.200891        0.969501   \n",
      "4       ...        -20.075283       -0.136989        0.220475        0.965725   \n",
      "...     ...               ...             ...             ...             ...   \n",
      "125259  ...        -20.707271       -0.110854        0.041843        0.992955   \n",
      "125260  ...        -20.707271       -0.110854        0.041843        0.992955   \n",
      "125261  ...        -20.707271       -0.111009        0.041794        0.992940   \n",
      "125262  ...        -20.707271       -0.111009        0.041794        0.992940   \n",
      "125263  ...        -20.707271       -0.111009        0.041794        0.992940   \n",
      "\n",
      "        eye_center1_3d_x  eye_center1_3d_y  eye_center1_3d_z  gaze_normal1_x  \\\n",
      "0                    NaN               NaN               NaN             NaN   \n",
      "1                    NaN               NaN               NaN             NaN   \n",
      "2                    NaN               NaN               NaN             NaN   \n",
      "3                    NaN               NaN               NaN             NaN   \n",
      "4                    NaN               NaN               NaN             NaN   \n",
      "...                  ...               ...               ...             ...   \n",
      "125259        -37.372594         14.763454        -23.294339       -0.130868   \n",
      "125260        -37.372594         14.763454        -23.294339       -0.132037   \n",
      "125261        -37.372594         14.763454        -23.294339       -0.132037   \n",
      "125262        -37.372594         14.763454        -23.294339       -0.133311   \n",
      "125263        -37.372594         14.763454        -23.294339       -0.131320   \n",
      "\n",
      "        gaze_normal1_y  gaze_normal1_z  \n",
      "0                  NaN             NaN  \n",
      "1                  NaN             NaN  \n",
      "2                  NaN             NaN  \n",
      "3                  NaN             NaN  \n",
      "4                  NaN             NaN  \n",
      "...                ...             ...  \n",
      "125259        0.093021        0.987026  \n",
      "125260        0.091860        0.986979  \n",
      "125261        0.091860        0.986979  \n",
      "125262        0.091656        0.986827  \n",
      "125263        0.092941        0.986974  \n",
      "\n",
      "[125264 rows x 21 columns]\n"
     ]
    }
   ],
   "source": [
    "def ChangeTimestampForm():\n",
    "    df = openfile()\n",
    "    df[\"gaze_timestamp\"] = pandas.to_datetime(df[\"gaze_timestamp\"].values)\n",
    "    return df\n",
    "print(ChangeTimestampForm())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8b8948eb",
   "metadata": {},
   "source": [
    "## 第四题，数据的采样率"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "caaf5aea",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "427.62610766083765\n"
     ]
    }
   ],
   "source": [
    "def frequence():\n",
    "    df = openfile()\n",
    "    res = 1 / ((df[\"gaze_timestamp\"].iloc[-1] - df[\"gaze_timestamp\"].iloc[0]) / len(df))\n",
    "    return res\n",
    "print(frequence())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "04489d03",
   "metadata": {},
   "source": [
    "## 第五题，按照100Hz的频率重新采样 采样周期为0.01s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "3b4fd857",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                         world_index  confidence  norm_pos_x  norm_pos_y  \\\n",
      "gaze_timestamp                                                             \n",
      "1970-01-02 00:29:10.770          0.0    0.681690    0.437387    0.291906   \n",
      "1970-01-02 00:29:10.780          1.0    0.584288    0.437978    0.307110   \n",
      "1970-01-02 00:29:10.790          1.0    0.679988    0.494694    0.404853   \n",
      "1970-01-02 00:29:10.800          1.0    0.810370    0.494951    0.404822   \n",
      "1970-01-02 00:29:10.810          2.0    0.811268    0.494067    0.401053   \n",
      "1970-01-02 00:29:10.820          2.0    0.893564    0.493605    0.399335   \n",
      "1970-01-02 00:29:10.830          2.0    0.845289    0.493316    0.398559   \n",
      "1970-01-02 00:29:10.840          2.5    0.841835    0.492696    0.398804   \n",
      "1970-01-02 00:29:10.850          3.0    0.813601    0.492874    0.398257   \n",
      "1970-01-02 00:29:10.860          3.0    0.893743    0.492674    0.398524   \n",
      "1970-01-02 00:29:10.870          3.5    0.862389    0.492139    0.398724   \n",
      "1970-01-02 00:29:10.880          4.0    0.892706    0.492170    0.398582   \n",
      "1970-01-02 00:29:10.890          4.0    0.863562    0.491619    0.398328   \n",
      "1970-01-02 00:29:10.900          4.0    0.850346    0.491440    0.398221   \n",
      "1970-01-02 00:29:10.910          5.0    0.878314    0.491522    0.397330   \n",
      "1970-01-02 00:29:10.920          5.0    0.864336    0.491490    0.396538   \n",
      "1970-01-02 00:29:10.930          5.0    0.998242    0.491106    0.396239   \n",
      "1970-01-02 00:29:10.940          5.6    0.822405    0.491349    0.396675   \n",
      "1970-01-02 00:29:10.950          6.0    0.837220    0.491234    0.397143   \n",
      "1970-01-02 00:29:10.960          6.0    0.860573    0.490922    0.397230   \n",
      "\n",
      "                         gaze_point_3d_x  gaze_point_3d_y  gaze_point_3d_z  \\\n",
      "gaze_timestamp                                                               \n",
      "1970-01-02 00:29:10.770       -54.359308       103.262224       694.806989   \n",
      "1970-01-02 00:29:10.780       -42.813406        41.035419        10.103229   \n",
      "1970-01-02 00:29:10.790         1.979829       -20.040517      -292.334754   \n",
      "1970-01-02 00:29:10.800         1.859581       -19.717564      -287.721641   \n",
      "1970-01-02 00:29:10.810         2.204797       -20.676414      -290.218427   \n",
      "1970-01-02 00:29:10.820         2.409602       -21.335674      -294.369777   \n",
      "1970-01-02 00:29:10.830         2.512630       -21.451642      -293.704395   \n",
      "1970-01-02 00:29:10.840         2.767211       -21.566487      -295.993985   \n",
      "1970-01-02 00:29:10.850         2.711425       -21.777256      -297.274745   \n",
      "1970-01-02 00:29:10.860         2.798286       -21.804480      -298.433361   \n",
      "1970-01-02 00:29:10.870         3.005405       -21.779999      -298.687614   \n",
      "1970-01-02 00:29:10.880         3.002544       -21.876653      -299.589471   \n",
      "1970-01-02 00:29:10.890         3.227031       -22.022033      -300.826326   \n",
      "1970-01-02 00:29:10.900         3.300165       -22.075103      -301.234553   \n",
      "1970-01-02 00:29:10.910         3.278969       -22.336895      -302.166428   \n",
      "1970-01-02 00:29:10.920         3.308013       -22.621279      -303.673027   \n",
      "1970-01-02 00:29:10.930         3.462726       -22.723509      -304.165507   \n",
      "1970-01-02 00:29:10.940         3.365049       -22.609107      -303.908032   \n",
      "1970-01-02 00:29:10.950         3.410404       -22.507586      -303.923452   \n",
      "1970-01-02 00:29:10.960         3.540623       -22.548167      -304.725183   \n",
      "\n",
      "                         eye_center0_3d_x  eye_center0_3d_y  eye_center0_3d_z  \\\n",
      "gaze_timestamp                                                                  \n",
      "1970-01-02 00:29:10.770         -9.967464         14.998960        -20.037641   \n",
      "1970-01-02 00:29:10.780          0.021691         14.999306        -20.025094   \n",
      "1970-01-02 00:29:10.790         20.000000         15.000000        -20.000000   \n",
      "1970-01-02 00:29:10.800         20.000000         15.000000        -20.000000   \n",
      "1970-01-02 00:29:10.810         20.000000         15.000000        -20.000000   \n",
      "1970-01-02 00:29:10.820         20.000000         15.000000        -20.000000   \n",
      "1970-01-02 00:29:10.830         20.000000         15.000000        -20.000000   \n",
      "1970-01-02 00:29:10.840         20.000000         15.000000        -20.000000   \n",
      "1970-01-02 00:29:10.850         20.000000         15.000000        -20.000000   \n",
      "1970-01-02 00:29:10.860         20.000000         15.000000        -20.000000   \n",
      "1970-01-02 00:29:10.870         20.000000         15.000000        -20.000000   \n",
      "1970-01-02 00:29:10.880         20.000000         15.000000        -20.000000   \n",
      "1970-01-02 00:29:10.890         20.000000         15.000000        -20.000000   \n",
      "1970-01-02 00:29:10.900         20.000000         15.000000        -20.000000   \n",
      "1970-01-02 00:29:10.910         20.000000         15.000000        -20.000000   \n",
      "1970-01-02 00:29:10.920         20.000000         15.000000        -20.000000   \n",
      "1970-01-02 00:29:10.930         20.000000         15.000000        -20.000000   \n",
      "1970-01-02 00:29:10.940         20.000000         15.000000        -20.000000   \n",
      "1970-01-02 00:29:10.950         20.000000         15.000000        -20.000000   \n",
      "1970-01-02 00:29:10.960         20.000000         15.000000        -20.000000   \n",
      "\n",
      "                         gaze_normal0_x  gaze_normal0_y  gaze_normal0_z  \\\n",
      "gaze_timestamp                                                            \n",
      "1970-01-02 00:29:10.770       -0.061136        0.121556        0.984479   \n",
      "1970-01-02 00:29:10.780       -0.014355        0.095046        0.987478   \n",
      "1970-01-02 00:29:10.790        0.065145        0.027374        0.997500   \n",
      "1970-01-02 00:29:10.800        0.066672        0.024890        0.997463   \n",
      "1970-01-02 00:29:10.810        0.064772        0.024500        0.997599   \n",
      "1970-01-02 00:29:10.820        0.063058        0.025140        0.997693   \n",
      "1970-01-02 00:29:10.830        0.062845        0.027284        0.997650   \n",
      "1970-01-02 00:29:10.840        0.061422        0.025921        0.997775   \n",
      "1970-01-02 00:29:10.850        0.061335        0.026011        0.997778   \n",
      "1970-01-02 00:29:10.860        0.060777        0.025339        0.997830   \n",
      "1970-01-02 00:29:10.870        0.059995        0.025130        0.997882   \n",
      "1970-01-02 00:29:10.880        0.059813        0.025071        0.997894   \n",
      "1970-01-02 00:29:10.890        0.058765        0.024700        0.997966   \n",
      "1970-01-02 00:29:10.900        0.058422        0.024264        0.997997   \n",
      "1970-01-02 00:29:10.910        0.058302        0.025038        0.997985   \n",
      "1970-01-02 00:29:10.920        0.057891        0.025402        0.997999   \n",
      "1970-01-02 00:29:10.930        0.057256        0.025568        0.998032   \n",
      "1970-01-02 00:29:10.940        0.057648        0.025339        0.998015   \n",
      "1970-01-02 00:29:10.950        0.057488        0.024511        0.998045   \n",
      "1970-01-02 00:29:10.960        0.056879        0.024088        0.998090   \n",
      "\n",
      "                         eye_center1_3d_x  eye_center1_3d_y  eye_center1_3d_z  \\\n",
      "gaze_timestamp                                                                  \n",
      "1970-01-02 00:29:10.770               NaN               NaN               NaN   \n",
      "1970-01-02 00:29:10.780        -39.934928         14.997919        -20.075283   \n",
      "1970-01-02 00:29:10.790        -39.934928         14.997919        -20.075283   \n",
      "1970-01-02 00:29:10.800        -39.934928         14.997919        -20.075283   \n",
      "1970-01-02 00:29:10.810        -39.934928         14.997919        -20.075283   \n",
      "1970-01-02 00:29:10.820        -39.934928         14.997919        -20.075283   \n",
      "1970-01-02 00:29:10.830        -39.934928         14.997919        -20.075283   \n",
      "1970-01-02 00:29:10.840        -39.934928         14.997919        -20.075283   \n",
      "1970-01-02 00:29:10.850        -39.934928         14.997919        -20.075283   \n",
      "1970-01-02 00:29:10.860        -39.934928         14.997919        -20.075283   \n",
      "1970-01-02 00:29:10.870        -39.934928         14.997919        -20.075283   \n",
      "1970-01-02 00:29:10.880        -39.934928         14.997919        -20.075283   \n",
      "1970-01-02 00:29:10.890        -39.934928         14.997919        -20.075283   \n",
      "1970-01-02 00:29:10.900        -39.934928         14.997919        -20.075283   \n",
      "1970-01-02 00:29:10.910        -39.934928         14.997919        -20.075283   \n",
      "1970-01-02 00:29:10.920        -39.934928         14.997919        -20.075283   \n",
      "1970-01-02 00:29:10.930        -39.934928         14.997919        -20.075283   \n",
      "1970-01-02 00:29:10.940        -39.934928         14.997919        -20.075283   \n",
      "1970-01-02 00:29:10.950        -39.934928         14.997919        -20.075283   \n",
      "1970-01-02 00:29:10.960        -39.934928         14.997919        -20.075283   \n",
      "\n",
      "                         gaze_normal1_x  gaze_normal1_y  gaze_normal1_z  \n",
      "gaze_timestamp                                                           \n",
      "1970-01-02 00:29:10.770             NaN             NaN             NaN  \n",
      "1970-01-02 00:29:10.780       -0.145087        0.230744        0.962137  \n",
      "1970-01-02 00:29:10.790       -0.150232        0.224797        0.962738  \n",
      "1970-01-02 00:29:10.800       -0.152198        0.229156        0.961410  \n",
      "1970-01-02 00:29:10.810       -0.151952        0.234021        0.960284  \n",
      "1970-01-02 00:29:10.820       -0.150413        0.234215        0.960478  \n",
      "1970-01-02 00:29:10.830       -0.151138        0.233532        0.960531  \n",
      "1970-01-02 00:29:10.840       -0.150791        0.233569        0.960577  \n",
      "1970-01-02 00:29:10.850       -0.149916        0.233780        0.960662  \n",
      "1970-01-02 00:29:10.860       -0.149606        0.233583        0.960758  \n",
      "1970-01-02 00:29:10.870       -0.150185        0.233384        0.960716  \n",
      "1970-01-02 00:29:10.880       -0.149704        0.233300        0.960812  \n",
      "1970-01-02 00:29:10.890       -0.149820        0.233547        0.960734  \n",
      "1970-01-02 00:29:10.900       -0.149847        0.233968        0.960627  \n",
      "1970-01-02 00:29:10.910       -0.149284        0.234162        0.960668  \n",
      "1970-01-02 00:29:10.920       -0.148602        0.234394        0.960717  \n",
      "1970-01-02 00:29:10.930       -0.148867        0.234479        0.960655  \n",
      "1970-01-02 00:29:10.940       -0.148678        0.234164        0.960761  \n",
      "1970-01-02 00:29:10.950       -0.148821        0.234277        0.960712  \n",
      "1970-01-02 00:29:10.960       -0.148850        0.234256        0.960712  \n"
     ]
    }
   ],
   "source": [
    "def Resampling():\n",
    "    df = openfile()\n",
    "    df[\"gaze_timestamp\"] = pandas.to_datetime(df[\"gaze_timestamp\"].values,unit = \"s\")\n",
    "    df=df.resample(\"0.01S\",on = \"gaze_timestamp\").mean()\n",
    "    res = df.head(20)\n",
    "    return res\n",
    "print(Resampling())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "81e58553",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
